﻿using System;
using SGCG.Model;
using System.Windows.Input;
using System.Windows;
using System.Windows.Media;

namespace SGCG.Actions
{
    public class CreateCircleAction : BorderedObjectCreationAction<Circle>
    {
        public CreateCircleAction(PellBitmap pellBitmap) : base(pellBitmap) { }

        protected override Circle CreateObject(int x, int y)
        {
            return new Circle(null)
            {
                X = x,
                Y = y,
                Radius = 0,
                LineStyle = LineStyle.Normal,
                LineThickness = LineThickness.Normal,
                Color = Colors.Black
            };
        }

        protected override void SetPointCore(int point, int x, int y)
        {
            if (point == 2)
            {
                this.BorderedObject.Radius = (int)Math.Round(Math.Sqrt((x - this.BorderedObject.X)*(x - this.BorderedObject.X) + (y - this.BorderedObject.Y)*(y - this.BorderedObject.Y)));
            }
        }
    }
}
